#include <Arduino.h>
#include <Scheduler.h>
#include "app_log.h"
#include "app_config.h"
#include "app_mqtt.h"
#include "app_serialservo.h"

void setup()
{
    LOG_BAUDRATE(115200);
    LOG_INFO("\r\n");

    pinMode(0, OUTPUT);
    digitalWrite(0, LOW);
    bool isConnfig = digitalRead(2) == LOW;

    Serial1.begin(9600);

    auto *config_task = new ConfigTask(false, isConnfig);
    SchedulerClass::start(config_task);

    if (!config_task->configMode)
    {
        auto *network_task = new NetworkTask();

        auto *serial_servo_task = new SerialServoTask(network_task);

        SchedulerClass::start(serial_servo_task);
        SchedulerClass::start(network_task);
    }

    SchedulerClass::begin();
}

void loop()
{
}
